import { Component } from "@angular/core"
import { AlertController } from 'ionic-angular'
import { NativeStorage } from '@ionic-native/native-storage';
import { TranslateService } from '@ngx-translate/core';

import { FeedbackPage } from "./feedback/feedback";
import { CustPage } from "./cust/cust";
import { AboutusPage } from "./about/about";
import { LoginPage } from "../../login/login";
import { CusPage } from "./cus/cus";


import { SplashScreen } from '@ionic-native/splash-screen';
@Component({
    selector: 'page-set',
    templateUrl: 'set.html',
})

export class SetPage{
    feedbackPage = FeedbackPage
    custPage = CustPage
    aboutusPage = AboutusPage
    loginPage = LoginPage
    cusPage = CusPage
    constructor(
        private alertCtrl:AlertController,
        private translate: TranslateService,
        private stroge:NativeStorage,
        private splashscreen:SplashScreen
    ) {
        translate.setDefaultLang('en')
    }
    ionViewDidEnter(){
        this.stroge.getItem('lang').then(res=>{
            this.translate.use(res)
        })
    }
    presentConfirm() {
        let alert = this.alertCtrl.create({
            title: '',
            message: 'All of your cache will be cleared. This action cannot be undone.',
            buttons: [
            {
                text: 'Cancel',
                role: 'cancel',
                handler: () => {
                console.log('Cancel clicked');
                }
            },
            {
                text: 'Ok',
                handler: () => {
                console.log('Buy clicked');
                }
            }
            ]
        });
        alert.present();
    }
    quit(){
        let alert = this.alertCtrl.create({
            title: '',
            message: 'Exiting the account will clear your usage data on this machine.',
            buttons: [
            {
                text: 'Cancel',
                role: 'cancel',
                handler: () => {
                    
                }
            },
            {
                text: 'Ok',
                handler: () => {
                    this.stroge.clear();
                    this.splashscreen.show();
                    window.location.reload();
                }
            }
            ]
        });
        alert.present();
    }
}